home *** CD-ROM | disk | FTP | other *** search
/ Programming Microsoft Visual Basic .NET / Programming Microsoft Visual Basic .NET (Microsoft Press)(X08-78517)(2002).bin / setup / vbnet / 26 web services / moneyconverter / converter.asmx.vb < prev    next >
Encoding:
Text File  |  2002-03-19  |  2.0 KB  |  62 lines

  1. ' a very simple web service that exposes two methods
  2.  
  3. Imports System.Web.Services
  4.  
  5. <WebService(Description:="A web service for converting currencies", _
  6.     Namespace:="http://www.vb2themax.com/")> _
  7. Public Class Converter
  8.     Inherits System.Web.Services.WebService
  9.  
  10. #Region " Web Services Designer Generated Code "
  11.  
  12.     Public Sub New()
  13.         MyBase.New()
  14.  
  15.         'This call is required by the Web Services Designer.
  16.         InitializeComponent()
  17.  
  18.         'Add your own initialization code after the InitializeComponent() call
  19.  
  20.     End Sub
  21.  
  22.     'Required by the Web Services Designer
  23.     Private components As System.ComponentModel.IContainer
  24.  
  25.     'NOTE: The following procedure is required by the Web Services Designer
  26.     'It can be modified using the Web Services Designer.  
  27.     'Do not modify it using the code editor.
  28.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  29.         components = New System.ComponentModel.Container()
  30.     End Sub
  31.  
  32.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  33.         'CODEGEN: This procedure is required by the Web Services Designer
  34.         'Do not modify it using the code editor.
  35.         If disposing Then
  36.             If Not (components Is Nothing) Then
  37.                 components.Dispose()
  38.             End If
  39.         End If
  40.         MyBase.Dispose(disposing)
  41.     End Sub
  42.  
  43. #End Region
  44.  
  45.     <WebMethod(Description:="Convert from Euro to Dollar currency")> _
  46.     Function EuroToDollar(ByVal amount As Decimal) As Decimal
  47.         Return amount * GetEuroToDollarConversionRate()
  48.     End Function
  49.  
  50.     <WebMethod(Description:="Convert from Dollar to Euro currency")> _
  51.     Function DollarToEuro(ByVal amount As Decimal) As Decimal
  52.         Return amount / GetEuroToDollarConversionRate()
  53.     End Function
  54.  
  55.     Private Function GetEuroToDollarConversionRate() As Decimal
  56.         ' In a real application this code would read a file or a database.
  57.         Return 0.9@
  58.     End Function
  59.  
  60. End Class
  61.  
  62.